package com.my.study.init.serverInit;

import cn.hutool.extra.spring.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@Slf4j
public class PaymentEvent implements ApplicationListener<ApplicationReadyEvent> {

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        // 启动完成初始化PaymentFactory中的bean
        log.info("PaymentService start init");
        Map<String, BasePaymentService> beansOfType = SpringUtil.getBeansOfType(BasePaymentService.class);
        PaymentFactory.setBeanMap(beansOfType);
        log.info("PaymentService end init");
    }
}
